module shifter(/*AUTOARG*/
   // Outputs
   o_shift_out,
   // Inputs
   clk, i_load, i_shift_in, i_load_data
   );
   parameter SHIFT_DIR = 0;	// 0:shift left; 1:shift right
   parameter WIDTH = 8;
   output logic o_shift_out;
   input logic 	clk, i_load;
   input logic 	i_shift_in;
   input logic [WIDTH-1:0] i_load_data;

   logic [WIDTH-1:0] 	   shift_regs;
   always_ff@(posedge clk)
     begin
	if(i_load)
	  begin
	       shift_regs <= i_load_data;
	  end
	else
	  begin
	     if(SHIFT_DIR)	// shift right
	       shift_regs <= {i_shift_in, shift_regs[WIDTH-1:1]};
	     else
	       shift_regs <= {shift_regs[WIDTH-2:0], i_shift_in};
	  end
     end
   
   assign o_shift_out = SHIFT_DIR ? shift_regs[0] : shift_regs[WIDTH-1];
endmodule // shifter
